package com.binvshe.binvshe.account.ui;

import android.content.Context;
import android.content.Intent;
import android.net.http.SslError;
import android.os.Bundle;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.webkit.SslErrorHandler;
import android.webkit.WebSettings;
import android.webkit.WebView;
import android.webkit.WebViewClient;

import com.binvshe.binvshe.R;
import com.binvshe.binvshe.common.http.UrlCenter;
import com.pachong.android.baseuicomponent.activity.BaseActivity;

import butterknife.Bind;

public class ServiceAgreementActivity extends BaseActivity {

    @Bind(R.id.mWvService)
    WebView mWvService;

    public static void start(Context context) {
        Intent starter = new Intent(context, ServiceAgreementActivity.class);
        context.startActivity(starter);
    }

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setTitle("Modo服务协议");
        enableBackButton();
        setWebview();
    }

    private void setWebview() {
        WebSettings settings = mWvService.getSettings();
        settings.setJavaScriptEnabled(true);
        mWvService.loadUrl(UrlCenter.PROTOCOL);
        mWvService.setWebViewClient(new WebViewClient() {
            @Override
            public void onReceivedSslError(WebView view, SslErrorHandler handler, SslError error) {
                handler.proceed();
            }
        });
    }

    @Override
    public View createDataView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
        return inflater.inflate(R.layout.act_service_agreement, null);
    }
}
